export default {
  // 开启命名空间
  namespaced: true,

  // state 数据
  state: () => ({
    // address: JSON.parse(uni.getStorageSync('address') || '{}'),
    // address:{}
    userType: JSON.parse(uni.getStorageSync('userType') || '{}'), //业主、管理员、维修人员
    userInfo: JSON.parse(uni.getStorageSync('userInfo') || '{}'),//用户信息
    // 业主tabbar
    tabBarList1: [{
        "pagePath": "/pages/home/home",
        "text": "首页",
        "iconPath": "/static/tab_icons/home.png",
        "selectedIconPath": "/static/tab_icons/home-active.png"
      }, {
        "pagePath": "/pages/repair/repair",
        "text": "报修",
        "iconPath": "/static/tab_icons/repair.png",
        "selectedIconPath": "/static/tab_icons/repair-active.png"
      },
      {
        "pagePath": "/pages/itegral/itegral",
        "text": "积分商城",
        "iconPath": "/static/tab_icons/itegral.png",
        "selectedIconPath": "/static/tab_icons/itegral-active.png"
      },
      {
        "pagePath": "/pages/my/my",
        "text": "我的",
        "iconPath": "/static/tab_icons/my.png",
        "selectedIconPath": "/static/tab_icons/my-active.png"
      }
    ],
    // 管理员tabbar
    tabBarList2: [{
        "pagePath": "/pages/admin-people/admin-people",
        "text": "人员管理",
        "iconPath": "/static/tab_icons/admin-people.png",
        "selectedIconPath": "/static/tab_icons/admin-people-active.png"
      }, {
        "pagePath": "/pages/admin-page/admin-page",
        "text": "页面管理",
        "iconPath": "/static/tab_icons/admin-page.png",
        "selectedIconPath": "/static/tab_icons/admin-page-active.png"
      },
      {
        "pagePath": "/pages/admin-business/admin-business",
        "text": "业务管理",
        "iconPath": "/static/tab_icons/admin-business.png",
        "selectedIconPath": "/static/tab_icons/admin-business-active.png"
      }
    ],
    // 维修人员tabbar
    tabBarList3: [{
      "pagePath": "/pages/home/home",
      "text": "首页",
      "iconPath": "/static/tab_icons/home.png",
      "selectedIconPath": "/static/tab_icons/home-active.png"
    }, {
      "pagePath": "/pages/weixiu-people/weixiu-people",
      "text": "维修",
      "iconPath": "/static/tab_icons/repair.png",
      "selectedIconPath": "/static/tab_icons/repair-active.png"
    }],
    // 维修人员信息表格==>表头（列名）
    workercolumn: [{
        type: 'selection',
        fixed: true,
        width: 60
      },
      {
        name: 'name',
        label: '姓名',
        fixed: true,
        width: 100,
        emptyString: '--'
      },
      {
        name: 'sex',
        label: '性别',
        width: 60,
        // filters: {
        //   0: '男',
        //   1: '女'
        // }
      },
      {
        name: 'age',
        label: '年龄',
        sorter: true,
        align: 'right',
        fixed: false,
        width: 60,
      },
      {
        name: 'img',
        label: '照片',
        type: "img",
        align: "center"
      },
      {
        name: 'address',
        label: '地址'
      },
      {
        name: 'tel',
        label: '电话'
      },
      {
        name: 'username',
        label: '账号'
      },
      {
        name: 'password',
        label: '密码'
      },
      {
        name: 'status',
        label: '状态',
      },
      // {
      //   name: 'province',
      //   label: '省份'
      // },
      // {
      //   name: 'city',
      //   label: '城市'
      // },
      // {
      //   name: 'zip',
      //   label: '邮编'
      // },
      // {
      //   name: 'operation',
      //   type: 'operation',
      //   label: '操作',
      //   renders: [{
      //       name: '编辑',
      //       class: 'edit',
      //       type: "primary",
      //       func: 'edit' // func 代表子元素点击的事件 父元素接收的事件 父元素 @edit
      //     },
      //     {
      //       name: '自定义按钮',
      //       type: 'custom', // type 为custom的时候自定义按钮
      //       class: "custom",
      //       func: 'custom'
      //     },
      //     {
      //       name: '删除',
      //       type: 'warn', // type 为custom的时候自定义按钮
      //       class: "del",
      //       func: 'dele',
      //     },
      //   ]
      // },
    ],
    // 业主信息表格==>表头（列名）
    usercolumn: [{
        type: 'selection',
        fixed: true,
        width: 60
      },
      {
        name: 'name',
        label: '姓名',
        fixed: true,
        width: 100,
        emptyString: '--'
      },
      {
        name: 'sex',
        label: '性别',
        width: 60,
        // filters: {
        //   0: '男',
        //   1: '女'
        // }
      },
      {
        name: 'age',
        label: '年龄',
        sorter: true,
        align: 'right',
        fixed: false,
        width: 60,
      },
      {
        name: 'img',
        label: '照片',
        type: "img",
        align: "center"
      },
      {
        name: 'tel',
        label: '电话',
      },
      {
        name: 'address',
        label: '地址'
      },
      {
        name: 'username',
        label: '账号'
      },
      {
        name: 'password',
        label: '密码'
      },
      // {
      //   name: 'status',
      //   label: '状态',
      // },
      // {
      //   name: 'province',
      //   label: '省份'
      // },
      // {
      //   name: 'city',
      //   label: '城市'
      // },
      // {
      //   name: 'zip',
      //   label: '邮编'
      // },
      // {
      //   name: 'operation',
      //   type: 'operation',
      //   label: '操作',
      //   renders: [{
      //       name: '编辑',
      //       class: 'edit',
      //       type: "primary",
      //       func: 'edit' // func 代表子元素点击的事件 父元素接收的事件 父元素 @edit
      //     },
      //     {
      //       name: '自定义按钮',
      //       type: 'custom', // type 为custom的时候自定义按钮
      //       class: "custom",
      //       func: 'custom'
      //     },
      //     {
      //       name: '删除',
      //       type: 'warn', // type 为custom的时候自定义按钮
      //       class: "del",
      //       func: 'dele',
      //     },
      //   ]
      // },
    ],
    // 业主信息表格==>数据内容（死数据，后续获取数据库即可）
    userData: [{
        id: "0",
        // checked: true,
        name: '业主1',
        sex: '男',
        age: 22,
        phone:'1848894894',
        img: "https://img1.baidu.com/it/u=300787145,1214060415&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",
        address: '上海市普上海市普上海市普上海市普',
        username: "6a4w46da",
        password: "54wq48d4",
      },
      {
          id: "1",
          // checked: true,
          name: '业主2',
          sex: '男',
          age: 22,
          phone:'48489416451',
          img: "https://img1.baidu.com/it/u=300787145,1214060415&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",
          address: '上海市普上海市普上海市普上海市普',
          username: "6a4w46da",
          password: "54wq48d4",
        },
        {
            id: "2",
            // checked: true,
            name: '业主3',
            sex: '女',
            age: 22,
            phone:'1484984611',
            img: "https://img1.baidu.com/it/u=300787145,1214060415&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",
            address: '上海市普上海市普上海市普上海市普',
            username: "6a4w46da",
            password: "54wq48d4",
          },
          {
              id: "3",
              // checked: true,
              name: '业主4',
              sex: '男',
              age: 32,
              phone:'17884644844864',
              img: "https://img1.baidu.com/it/u=300787145,1214060415&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",
              address: '上海市普上海市普上海市普上海市普',
              username: "6a4w46da",
              password: "54wq48d4",
            },
    ],
    // 维修人员信息表格==>数据内容（死数据，后续获取数据库即可）
    workerData: [{
        id: "0",
        // checked: true,
        name: '管理员',
        sex: '男',
        age: 22,
        img: "https://img1.baidu.com/it/u=300787145,1214060415&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",
        address: '上海市普上海市普上海市普上海市普',
        username: "admin",
        password: "admin",
        status: "在职",
      },
      {
        id: "1",
        // checked: true,
        name: '张三',
        sex: '男',
        age: 26,
        img: "https://img1.baidu.com/it/u=300787145,1214060415&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",
        address: '山东省泰安市新泰市',
        username: "zhangsan",
        password: "123456",
        status: "在职",
      },
      {
        id: "2",
        // checked: true,
        name: '李四',
        sex: '女',
        age: 23,
        img: "https://img1.baidu.com/it/u=300787145,1214060415&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",
        address: '山东省菏泽市',
        username: "lisi",
        password: "123456",
        status: "在职",
      },
      {
        id: "3",
        // checked: true,
        name: '王五',
        sex: '男',
        age: 32,
        img: "https://img1.baidu.com/it/u=300787145,1214060415&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",
        address: '北京市朝阳区',
        username: "wangwu",
        password: "123456",
        status: "离职",
      },
      {
        id: "4",
        // checked: true,
        name: '赵六',
        sex: '女',
        age: 35,
        img: "https://img1.baidu.com/it/u=300787145,1214060415&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",
        address: '山东省济南市高新区',
        username: "zhaoliu",
        password: "123456",
        status: "在职",
      }, {
        id: "5",
        // checked: true,
        name: '王小虎1',
        sex: '男',
        age: 35,
        img: "https://img1.baidu.com/it/u=300787145,1214060415&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",
        address: '山东省济南市高新区',
        username: "username",
        password: "123456",
        status: "在职",
      }, {
        id: "6",
        // checked: true,
        name: '王小虎2',
        sex: '男',
        age: 35,
        img: "https://img1.baidu.com/it/u=300787145,1214060415&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",
        address: '山东省济南市高新区',
        username: "username",
        password: "123456",
        status: "在职",
      }, {
        id: "7",
        // checked: true,
        name: '王小虎3',
        sex: '男',
        age: 38,
        img: "https://img1.baidu.com/it/u=300787145,1214060415&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",
        address: '山东省济南市高新区',
        username: "username",
        password: "123456",
        status: "在职",
      }, {
        id: "8",
        // checked: true,
        name: '王小虎4',
        sex: '男',
        age: 20,
        img: "https://img1.baidu.com/it/u=300787145,1214060415&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",
        address: '山东省济南市高新区',
        username: "username",
        password: "123456",
        status: "在职",
      }, {
        id: "9",
        // checked: true,
        name: '王小虎5',
        sex: '男',
        age: 33,
        img: "https://img1.baidu.com/it/u=300787145,1214060415&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",
        address: '山东省济南市高新区',
        username: "username",
        password: "123456",
        status: "在职",
      }, {
        id: "10",
        // checked: true,
        name: '王小虎6',
        sex: '女',
        age: 28,
        img: "https://img1.baidu.com/it/u=300787145,1214060415&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",
        address: '山东省济南市高新区',
        username: "username",
        password: "123456",
        status: "在职",
      }
    ],
    // 维修人员信息表格==>表头（列名）
    goodscolumn:[
      {
          type: 'selection',
          fixed: true,
          width: 60
        },
        {
          name: 'name',
          label: '商品名',
          fixed: true,
          width: 90,
          emptyString: '--'
        },
        {
          name: 'img',
          label: '图片',
          type: "img",
          align: "center"
        },
        {
          name: 'price',
          label: '所需积分',
          width: 90,
        },
    ],
    // 积分商城 商品信息表格==>数据内容（死数据，后续获取数据库即可）
    goodsData:[{
        id: "0",
        // checked: true,
        name: '肥皂',
        img: "https://img1.baidu.com/it/u=300787145,1214060415&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",
        price: "15",
      },{
        id: "1",
        // checked: true,
        name: '洗衣液',
        img: "https://img1.baidu.com/it/u=300787145,1214060415&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",
        price: "35",
      },{
        id: "2",
        // checked: true,
        name: '垃圾袋',
        img: "https://img1.baidu.com/it/u=300787145,1214060415&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",
        price: "5",
      },{
        id: "3",
        // checked: true,
        name: '鞋刷',
        img: "https://img1.baidu.com/it/u=300787145,1214060415&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",
        price: "15",
      },{
        id: "4",
        // checked: true,
        name: '洁厕灵',
        img: "https://img1.baidu.com/it/u=300787145,1214060415&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",
        price: "20",
      },{
        id: "5",
        // checked: true,
        name: '马桶垫',
        img: "https://img1.baidu.com/it/u=300787145,1214060415&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",
        price: "10",
      },
    ],
  }),

  // 方法
  mutations: {
    // 更新userType
    updateUserType(state, userType) {
      state.userType = userType
      // 通过 this.commit() 方法，调用 m_user 模块下的 saveUserTypeToStorage 方法将 userType 对象持久化存储到本地
      this.commit('m_user/saveUserTypeToStorage')
    },
    // 更新userInfo
    updateUserInfo(state, userInfo) {
      state.userInfo = userInfo
      // 通过 this.commit() 方法，调用 m_user 模块下的 saveUserInfoToStorage 方法将 userInfo 对象持久化存储到本地
      this.commit('m_user/saveUserInfoToStorage')
    },
    //  定义将 userType 持久化存储到本地 mutations 方法
    saveUserTypeToStorage(state) {
      uni.setStorageSync('userType', JSON.stringify(state.userType))
    },
    //  定义将 userInfo 持久化存储到本地 mutations 方法
    saveUserInfoToStorage(state) {
      uni.setStorageSync('userInfo', JSON.stringify(state.userInfo))
    },
  },

  // 数据包装器
  getters: {
    // 收货详细地址的计算属性
    // addstr(state) {
    //   if (!state.address.provinceName) return ''

    //   // 拼接 省，市，区，详细地址 的字符串并返回给用户
    //   return state.address.provinceName + state.address.cityName + state.address.countyName + state.address.detailInfo
    // }
  },
}
